// RemoveReadOnly.h
// (c) 2008, Charles Lechasseur
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef REMOVEREADONLY_H
#define REMOVEREADONLY_H

#pragma once

#include "COM/ClassFactory.h"
#include "COM/Object.h"
#include <windows.h>
#include <shobjidl.h>


namespace RRO
{
    //
    // COM object handing the core of the RemoveReadOnly contextual menu extension.
    //
    class RemoveReadOnly : public COM::Object<COM::ObjectBase<IContextMenu>, IID_IContextMenu, IContextMenu>
    {
    public:
                                RemoveReadOnly(void);
        virtual                 ~RemoveReadOnly(void);

        // IContextMenu methods
        STDMETHOD(QueryContextMenu)(HMENU p_hMenu, UINT p_FirstItemIndex,
            UINT p_FirstCmdID, UINT p_LastCmdID, UINT p_Flags);
        STDMETHOD(InvokeCommand)(CMINVOKECOMMANDINFO* p_pCommandInfo);
        STDMETHOD(GetCommandString)(UINT_PTR p_CmdId, UINT p_Flags,
            UINT* p_pReserved, LPSTR p_pName, UINT p_NameBufSize);

    private:
        // THESE METHODS ARE NOT IMPLEMENTED.
                                RemoveReadOnly(const RemoveReadOnly&);
        RemoveReadOnly&         operator=(const RemoveReadOnly&);
    };

    //
    // RemoveReadOnly class factory implementation.
    // Will take care of adding information in the registry to associate our extension with
    // all files and folders in the shell.
    //
    class RemoveReadOnlyFactory : public COM::ClassFactory
    {
    public:
                                    RemoveReadOnlyFactory(void);
        virtual                     ~RemoveReadOnlyFactory(void);

    private:
        // THESE METHODS ARE NOT IMPLEMENTED.
                                    RemoveReadOnlyFactory(const RemoveReadOnlyFactory&);
        RemoveReadOnlyFactory&      operator=(const RemoveReadOnlyFactory&);
    };

}; // namespace RRO


#endif REMOVEREADONLY_H
